package com.jdk8datedemo;

import java.time.LocalTime;

public class LocalTimeDemo {
    public static void main(String[] args) {
        //获取本地时间的日历对象。(包含时分秒)
        LocalTime now = LocalTime.now();
        System.out.println(now);

        int hour = now.getHour();//小时
        System.out.println(hour);

        int minute = now.getMinute();//分钟
        System.out.println(minute);

        int second = now.getSecond();//秒钟
        System.out.println(second);

        int nano = now.getNano();//纳秒
        System.out.println(nano);

        System.out.println(LocalTime.of(8,20));
        System.out.println(LocalTime.of(8,20,30));
        System.out.println(LocalTime.of(8,20,30,150));

        LocalTime time = LocalTime.of(8, 20, 30, 150);
        //is系列方法
        System.out.println(now.isBefore(time));
        System.out.println(now.isAfter(time));

        //with系列方法,只能修改时、分、秒
        System.out.println(time.withHour(10));

        //minus系列方法,只能减少时、分、秒
        System.out.println(time.minusHours(2));

        //plus系列方法,只能增加时、分、秒
        System.out.println(time.plusHours(1));
    }
}
